//商品管理
var url = require('url');
var template = require('templateConfig');
var main = require('main');
var module= require('module');
var form = require('form');

//模板配置
var tplArr = [];
var productManagerTpl =require('raw!../template/product-manager.txt'); 
tplArr['product-manager'] = template.compile(productManagerTpl.replace(/^\s*|\s*$/g, "")); 

//数据平铺
var data1 = {"list":[
				{"name":"商品数","key":"10"},
				{"name":"上架商品","key":"10"},
				{"name":"仓库商品","key":"0"},
			]};

var goodsInfo = {
    "id": 1,
    "title":"大家乐文胸一片式无痕内衣厚B杯深V聚拢商场同款内衣1",
    "attr": [],
    "num":"1002837828372",
    "spec":"大红,B杯,34/75",
    "quantity":"1",
    "inStock":"258",
};
var data2 = [
            	{
            		"id":"",
            		"num":"12321231",
            		"goodsInfo": module.ordersGoodsInfo([goodsInfo]),
            		"editUrl":"#",
            		"price":"99.10",
            	},{
            		"id":"",
            		"num":"12321232",
            		"goodsInfo": module.ordersGoodsInfo([goodsInfo]),
            		"editUrl":"#",
            		"price":"99.20",
            	},{
            		"id":"",
            		"num":"12321233",
            		"goodsInfo": module.ordersGoodsInfo([goodsInfo]),
            		"editUrl":"#",
            		"price":"99.30",
            	}
            ];

function Index(){
    _this = this;
    this.main = function(){
        main.event(this,'tap','i-click'); 
        this.init();
    }
    //初始化内容
    this.createHtml = function(){
    	var html = module.getModule('','storesInfoBrief')+
            	   module.getModule(data1,'InfoTiled')+
            	   _this.productManagerList();
        console.log(html);
    	$('.ui-container').html(html);
    }
    this.productManagerList = function(){
    	var data= {
            "tType": "productManagerList",
            "list": data2
        }
        return tplArr['product-manager'](data);
    }
    this.init= function(){ 
    	this.createHtml();
    }
    return this.main();
};

var index = new Index();